home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13073 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  57 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.sfasu.edu!not-for-mail
  3. From: Sanjay Prabhakaran <sanjayp%hp9000@pcsbom.patni.com>
  4. Subject: Re: Allocating memory in windows programs
  5. Message-ID: <3177cc$5530.2e@news.sfasu.edu>
  6. Date: Sat, 23 Mar 1996 11:05:48 GMT
  7.  
  8. dwnw%mimi@magic.itg.ti.com (Doug Nintzel) writes:
  9. > Hello, I am new at windows programming. I am using MS-SDK/c++. I am using the 
  10. > below code to allocate memory....
  11. > /****************************************************************************/
  12. > memtst()
  13. > {
  14. > char FAR*str;
  15. > i=0;
  16. > /* 
  17. > if((str=(char*)malloc(sizev))==NULL){MessageBox(hWnd,"GlobLock()failed","globl
  18. > ock",MB_OK);return(0);}
  19. >    for(i=0;i<555;++i)str[i]='x';str[25]='\0';
  20. >  */
  21. > if((hmem=GlobalAlloc(GHND,100))==NULL){MessageBox(hWnd,"GlobAlloc(),
  22. >     failed",MB_OK);return(0);}
  23. > str=(char FAR*)GlobalLock(hmem);
  24. > if(str==NULL){MessageBox(hWnd,"GlobLock()failed","globlock",MB_OK);return(0);}
  25. > MessageBox(hWnd,str,"ALLOC/LOCK OK",MB_OK);
  26. > strcpy(str,"mem test ok");
  27. > MessageBox(hWnd,str,"str content",MB_OK);
  28. > }
  29. > /****************************************************************************/
  30. > ...it crashes at strcpy(str,"mem test ok");...
  31. > I have also tried to used the commented out malloc() test instead of     
  32. > GlobalAlloc().
  33. > I have tried several other changes/combinations w/no luck. 
  34. > I have also checked c++ FAQ's and checked several book stores.
  35. > I am running out of ideas!!!...Please help.....
  36. > Thanks, Doug
  37.  
  38.  
  39. Hi,
  40.   Even I'am new to windows programming.
  41.   anyway are U using MSVCRT10.DLL 
  42.    I think all the standard C functions are present in that
  43.    so it could be the problem
  44.  
  45. Bye
  46.  sanjayp%hp9000@pcsbom.patni.com
  47.  Sanjay Prabhakaran
  48.   
  49.  
  50.  
  51.  
  52.